package com.souku.finance.application.ui.login;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.manager.RequestManager;
import com.souku.finance.application.R;
import com.souku.finance.application.adapter.RegisterGiftAdapter;
import com.souku.finance.application.base.BaseTitleBarActivity;
import com.souku.finance.application.bean.RegisterSucceedBean;
import com.souku.finance.application.http.UrlConstact;
import com.souku.finance.application.http.volley.ReqListener;
import com.souku.finance.application.http.volley.Success;
import com.souku.finance.application.ui.MainActivity;
import com.souku.finance.application.utils.JsonUtil;
import com.souku.finance.application.utils.ParamUtil;
import com.souku.finance.application.utils.ToastUtil;
import com.souku.finance.application.utils.level.LogUtils;
import com.souku.finance.application.utils.level.UIUtils;
import com.souku.finance.application.widget.MyListView;
import com.souku.finance.application.widget.titlebar.EaseTitleBar;

import java.util.HashMap;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RegisterSucceedActivity extends BaseTitleBarActivity {

    @BindView(R.id.title_bar)
    EaseTitleBar titleBar;
    @BindView(R.id.iv_blue_tick)
    ImageView ivBlueTick;
    @BindView(R.id.lv_list)
    MyListView lvList;
    @BindView(R.id.tv_go)
    TextView tvGo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register_succeed);
        ButterKnife.bind(this);
        surprise();
    }

    @Override
    public void internet() {

    }

    public void onClickTitleRightView(View v) {

    }

    @OnClick(R.id.tv_go)
    public void onViewClicked() {
        Intent intent = new Intent(RegisterSucceedActivity.this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    public void surprise() {
        HashMap<String, String> map = ParamUtil.getParams();
        RequestManager.getInstance().post(UrlConstact.SURPRISE, ParamUtil.getSing(map), new ReqListener(this, new Success() {
            @Override
            public void onSuccess(String response) {
                if (JsonUtil.getCode(response) == 1) {
                    RegisterSucceedBean bean = JsonUtil.fastBean(response, RegisterSucceedBean.class);
                    RegisterGiftAdapter adapter = new RegisterGiftAdapter(RegisterSucceedActivity.this, bean.list);
                    lvList.setAdapter(adapter);
                } else {
                    UIUtils.showToastSafe(JsonUtil.getMessage(response));
                }
            }
        }), ParamUtil.getHeaders());
    }

}
